// HTMLParseDlg.h : header file
//

#if !defined(AFX_HTMLPARSEDLG_H__25D882E8_98F7_4A8F_8252_6F602B52E95E__INCLUDED_)
#define AFX_HTMLPARSEDLG_H__25D882E8_98F7_4A8F_8252_6F602B52E95E__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "Parse.h"
#include "HttpDownload.h"
#include "SoftSearchDB.h"
#include "TVCritSec.h"
#include "TVThread.h"
#include "DownProcess.h"
#include "afxwin.h"
#include "afxcmn.h"

/////////////////////////////////////////////////////////////////////////////
// CHTMLParseDlg dialog

//##ModelId=450DFB69006E
class CHTMLParseDlg : public CDialog, public CTVThread
{
// Construction
public:
	//##ModelId=450DFB69007E
	CHTMLParseDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	//{{AFX_DATA(CHTMLParseDlg)
	enum { IDD = IDD_HTMLPARSE_DIALOG };
	CTreeCtrl	m_treeSite;
	CEdit	m_edtReport;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CHTMLParseDlg)
	protected:
	//##ModelId=450DFB69008E
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//##ModelId=450DFB690091
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CHTMLParseDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnBtnStart();
	afx_msg void OnDestroy();
	afx_msg void OnTimer(UINT nIDEvent);
	afx_msg LRESULT OnDownloadProcessEnd(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnDownloadProgress(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnDeleteSite(WPARAM wParam, LPARAM lParam);
	afx_msg LRESULT OnShowLogMsg(WPARAM wParam, LPARAM lParam);
	afx_msg void OnBtnStop();
	afx_msg void OnBtnHide();
	afx_msg void OnBtnSelectall();
	afx_msg void OnBtnReverseselect();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

protected:
	bool m_bWantStop;
	bool m_bOnlyGetlen;
	void ThreadProcMain(void);

private:
	void InitTreeSite();
	void DeleteTreeSite( SITE_INFO* pSiteInfo);
	void DbgPrint();
	void threadDownloadProcess();
	void threadDownloadEndProcess();
	long DownloadComplete(UINT nSiteID, HTTPDOWNLOAD& httpDownload);
	long DownloadRSSComplete( SITE_INFO* pSiteInfo, HTTPDOWNLOAD& httpDownload);
	long DownloadFileComplete( SITE_INFO* pSiteInfo, HTTPDOWNLOAD& httpDownload);
	void Test();
	SITE_INFO* FindSite(int nSiteID);
	void DeleteSite(int nSiteID);

private:
	CImageList m_ImageList;
	PARSE_TYPE m_parseType;
	CSoftSearchDB m_DB;
	CTVCritSec m_lock;
	list<SITE_INFO> m_listSiteInfo;
	map<UINT, CDownProcess*> m_mapDownProcessPtr;
	CString m_sInternetFileFolder;

public:
	afx_msg void OnBnClickedBtnResetsel();
	UINT m_nMaxThread;
	afx_msg void OnClose();
	afx_msg void OnBnClickedRdHtml();
	afx_msg void OnBnClickedRdRssxml();
	afx_msg void OnBnClickedRdDownfile();
	CProgressCtrl m_progress_download;
	CButton m_btnOnlyGetlen;
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_HTMLPARSEDLG_H__25D882E8_98F7_4A8F_8252_6F602B52E95E__INCLUDED_)
